<?php

namespace Ionafan2\GetonlyimgBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="urls")
 */
class Url {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;


    /**
     * @ORM\Column(name="domain", type="string")
     */
    protected $domain;


    /**
     * @Assert\Url
     * @ORM\Column(name="url", type="string")
     */
    protected $url;

    /**
     * @ORM\Column(name="url_scheme", type="string")
     */
    protected $urlScheme = 'http';


    /**
     * @ORM\Column(name="xpath_query", type="string")
     */
    protected $xpathQuery;


    /**
     * @var ArrayCollection
     *
     *  @ORM\OneToMany(targetEntity="Image", mappedBy="url", cascade={"persist"})
     */
    protected $images;

    function __construct()
    {
        $this->images = new ArrayCollection();
    }

    /**
     * @param Image $image
     */
    public function setImages($image)
    {
       $this->images->add($image);
       $image->setUrl($this);
    }

    /**
     * @return ArrayCollection
     */
    public function getImages()
    {
        return $this->images;
    }

    /**
     * @param mixed $url
     */
    public function setUrl($url)
    {
        $this->url = $url;
    }

    /**
     * @return mixed
     */
    public function getUrl()
    {
        return $this->url;
    }

    /**
     * @param mixed $xpathQuery
     */
    public function setXpathQuery($xpathQuery)
    {
        $this->xpathQuery = $xpathQuery;
    }

    /**
     * @return mixed
     */
    public function getXpathQuery()
    {
        return $this->xpathQuery;
    }

    /**
     * @param mixed $schema
     */
    public function setSchema($schema)
    {
        $this->schema = $schema;
    }

    /**
     * @return mixed
     */
    public function getSchema()
    {
        return $this->schema;
    }


}

